package com.UnionPayCenter.account.enums;

import com.UnionPayCenter.enums.CodeBaseEnum;
import com.UnionPayCenter.exception.ApiException;

public enum ChargeStatusEnum implements CodeBaseEnum {
    //状态: 00 待充值,01 充值中,03 成功,04 失败

    TO_CHARGE(0, "待充值"),
    CHARGEING(1, "充值中"),

    // 和支付状态保持一致
    SUCCESS(3, "支付成功"),
    FAIL(4, "支付失败");

    private int code;

    private String msg;

    ChargeStatusEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ChargeStatusEnum getEnum(int code) {
        for (ChargeStatusEnum ele : ChargeStatusEnum.values()) {
            if (ele.code == code) {
                return ele;
            }
        }
        throw new ApiException(404, "不正确的充值状态码");
    }

    @Override
    public int code() {
        return this.code;
    }

    @Override
    public String msg() {
        return this.msg;
    }
}
